# 部分模块的通用编译规则

C_OBJS = $(patsubst %.c, $(MOD_OBJS_DIR)/%.o, $(notdir $(C_SOURCE)))
VPATH += $(shell pwd)


all: dep_info $(LIBS)
ifeq ($(INPUT_ENTRY_FILE), 1)
	@echo -n " $(LIBDIR)/$(LIBS) " >> $(ENTRY_FILE)
else ifeq ($(LD_ORDER), -1)
	@echo -n " -l$(LIB_BASE_NAME) " >> $(LDFLAGS_FILE1)
else ifeq ($(LD_ORDER), -2)
	@echo -n " -l$(LIB_BASE_NAME) " >> $(LDFLAGS_FILE2)
else ifeq ($(LD_ORDER), -3)
	@echo -n " -l$(LIB_BASE_NAME) " >> $(LDFLAGS_FILE3)
else
	@echo -n " -l$(LIB_BASE_NAME) " >> $(LDFLAGS_FILE)
endif
	@echo "Building $(LIBDIR)/$(LIBS) Done."

dep_info:
	@$(MKDIR) $(MOD_OBJS_DIR)
	@echo "Use Optimization Level $(OPTLVL) to build $(LIBS) ..."

$(LIBS): $(C_OBJS)
	@$(AR) cr $(LIBDIR)/$@ $^


$(C_OBJS): $(MOD_OBJS_DIR)/%.o: %.c
	@$(CC) $(CFLAGSLIB) -o $@ $<

clean:
	@echo "Clean all objs..."
	@$(RM) $(C_OBJS)

distclean: clean
	@echo "Clean $(LIBS)"
	@$(RM) $(LIBS)

.PHONY: all dep_info clean distclean

